# -*- coding:UTF-8 -*-
"""
@Project : pythonProject
@File    : Python-J06.py
@IDE     : PyCharm
@Author  : WorldWind(1772830365@qq.com)
@Address : China - HeiLongjiang - Herbin
@Date    : 2025/7/7 下午11:38
"""
# a.合并两个字典 {"a":1, "b":2} 和 {"c":3, "d":4}，若键重复则值相加
data1 = {
    "a": 1,
    "b": 2,
    "c": 100
}
data2 = {
    "c": 3,
    "d": 4,
    "a": 5
}
myDict = {}
for i in data1:
    if i in data2:
        myDict[i] = data1[i] + data2[i]
    else:
        myDict[i] = data1[i]
for i in data2:
    if i in data1:
        continue
    else:
        myDict[i] = data2[i]
print(myDict)



